package com.mytx.mapper;

import com.mytx.pojo.Donation;
import com.mytx.pojo.Forward;
import com.mytx.pojo.ForwardExample;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

public interface ForwardMapper {
    //--自定义查询：根据用户id查询 收到的转赠记录，并查询出 经办人以及依附主题 等 信息-
    List<Forward> queryReceivedForward(String uId);

    //<!--根据forwardId,查询forward自身信息已经关联的管理员（经手人）、依附的主题等信息-->
    Forward queryForward(String forwardId);

    /**
     * 返回包含 管理员 和捐赠对象的转赠信息
     *
     * @param forwardId
     * @return
     */
    Forward queryForward_v1(String forwardId);

    /**
     * 增加转发的捐赠金额
     *
     * @param fId
     * @param amount
     */
    @Select(" UPDATE forward  SET donation_amount =donation_amount+ #{amount},updated= #{updated} WHERE f_id = #{fId};select donation_amount  from forward where  f_id = #{fId}")
    BigDecimal incrementDonationAmount(@Param("fId") String fId, @Param("amount") BigDecimal amount, @Param("updated") Date updated);

    /**
     * 增加转发的评论数量
     *
     * @param fId
     */
    @Select(" UPDATE forward  SET comment_size =comment_size + 1 WHERE f_id = #{fId}")
    void incrementCommentSize(@Param("fId") String fId);

    /*------------------------------------------分割线----------------------------------------------------------------*/

    int countByExample(ForwardExample example);

    int deleteByExample(ForwardExample example);

    int deleteByPrimaryKey(String fId);

    int insert(Forward record);

    int insertSelective(Forward record);

    List<Forward> selectByExample(ForwardExample example);

    Forward selectByPrimaryKey(String fId);

    int updateByExampleSelective(@Param("record") Forward record, @Param("example") ForwardExample example);

    int updateByExample(@Param("record") Forward record, @Param("example") ForwardExample example);

    int updateByPrimaryKeySelective(Forward record);

    int updateByPrimaryKey(Forward record);


}